You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.5 KiB
46 lines
1.5 KiB
|
2 months ago
|
import React from "react";
|
||
|
|
import { getFloorBySlug } from "../../../lib/data";
|
||
|
|
import { ProductGrid } from "../../../components/ProductGrid";
|
||
|
|
|
||
|
|
export const revalidate = 300;
|
||
|
|
|
||
|
|
interface Props { params: { slug: string } }
|
||
|
|
|
||
|
|
export function generateMetadata({ params }: Props) {
|
||
|
|
const floor = getFloorBySlug(params.slug);
|
||
|
|
return {
|
||
|
|
title: floor ? `${floor.title} - LOG` : `频道 - LOG`,
|
||
|
|
description: floor?.hero?.subtitle ?? `${params.slug} 频道`
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
export default function ChannelPage({ params }: Props) {
|
||
|
|
const floor = getFloorBySlug(params.slug);
|
||
|
|
if (!floor) {
|
||
|
|
return (
|
||
|
|
<div className="mx-auto max-w-screen-2xl px-4 py-12">
|
||
|
|
<h1 className="text-2xl font-semibold">频道未找到</h1>
|
||
|
|
<p className="mt-2 text-gray-600">该频道暂未配置内容。</p>
|
||
|
|
<a className="mt-6 inline-block text-blue-600" href="/">返回首页</a>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
return (
|
||
|
|
<div className="mx-auto max-w-screen-2xl px-4 py-8 space-y-8">
|
||
|
|
<div className="flex items-center justify-between">
|
||
|
|
<h1 className="text-2xl font-semibold">{floor.title}</h1>
|
||
|
|
<a href="/" className="text-sm text-gray-600 hover:text-gray-900">返回首页</a>
|
||
|
|
</div>
|
||
|
|
{floor.hero && (
|
||
|
|
<a href={floor.hero.href ?? "#"} className="block rounded-lg overflow-hidden">
|
||
|
|
<img src={floor.hero.image} alt={floor.hero.title ?? floor.title} className="w-full object-cover aspect-[16/6]" />
|
||
|
|
</a>
|
||
|
|
)}
|
||
|
|
<ProductGrid items={floor.products} />
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|